package xmldatabase;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import xmldatabase.Newuser;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/*

 /**
 *
 * @author betty
 */
/**
 *
 * @author betty
 */
public class Updateuser {

    // 连接对象
    private Connection conn;
    // 传递sql语句
    private Statement stt = null;

    ResultSet rs;
    // 查询

    public void update(Newuser usertest) throws SQLException {

        conn = DBConnection.getConnection();
        stt = conn.createStatement();
        if (conn == null) {
            return;
        }

        String sql = "Update news set position = ?,phonenumber=?,email=?,gender=?,name=?,password=? where id =?";
        // 预处理sql语句
        PreparedStatement presta = conn.prepareStatement(sql);
        // 设置sql语句中的values值
        presta.setInt(1, usertest.pos);
        presta.setString(2, usertest.phnu);
        presta.setString(3, usertest.em);
        presta.setString(4, usertest.gen);
        presta.setString(5, usertest.nm);
        presta.setString(6, usertest.pw);
        presta.setInt(7, usertest.id);
        presta.execute();
    }
}
